package com.unknowpupil.web.component.wallet.tools;

import com.google.common.collect.Maps;
import com.unknowpupil.web.component.wallet.entity.Market;
import com.unknowpupil.web.component.wallet.utils.HttpClientResult;
import com.unknowpupil.web.component.wallet.utils.HttpClientUtils;
import com.unknowpupil.web.utils.MapperUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * @Classname: CoinMarketTools
 * @Author: <a> w10g </a>
 * @CreateDate: Create in 2019/10/19 1:26
 * @Description:
 * # 获取已开启的市场信息，包括价格、数量小数点位数
 * TPL_MARKETS = 'http://api.zb.com/data/v1/markets'
 * # 全币种行情
 * TPL_ALL_MARKET = 'http://api.zb.cn/data/v1/allTicker'
 * # 行情
 * TPL_MARKET = 'http://api.zb.com/data/v1/ticker?market={MARKET}'
 * # 市场深度
 * TPL_DEPTH = 'http://api.zb.com/data/v1/depth?market={MARKET}&size={SIZE}'
 * # 历史成交
 * TPL_TRADES = 'http://api.zb.com/data/v1/trades?market={MARKET}'
 * # k线
 * TPL_KLINE = 'http://api.zb.com/data/v1/kline?market={MARKET}'
 * @Version: 1.0
 */
@Component
public class CoinMarketTools {
//    final static String URL = "http://api.zb.com/data/v1/ticker";
    final static String COIN = "_qc";
    public Market getMarket(String currency){
        try {
            Map map = Maps.newHashMap();
            currency = StringUtils.lowerCase(currency);
            map.put("market",StringUtils.join(currency,COIN));
            String URL = "https://www.okcoin.com/api/v1/ticker.do?symbol=eth_usd";

            HttpClientResult httpClientResult = HttpClientUtils.doGet(URL,null);

            System.out.println(httpClientResult);
            Market market = MapperUtils.json2pojo(httpClientResult.getContent(), Market.class);


            return null;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return  null;
    }
}
